FROM registry.cn-shanghai.aliyuncs.com/star_base/golang-x86:1.23.1-alpine as builder

LABEL stage=gobuilder

# 环境变量
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct \
    GOPRIVATE=e.globalpand.cn \
    CGO_ENABLED=0 \
    GOOS=linux    \
    GOARCH=arm64

WORKDIR /application

RUN git config --global url."https://${GIT_USER}:${GIT_PWD}@codeup.aliyun.com/".insteadOf "https://codeup.aliyun.com/"

COPY . .


RUN go env
RUN go mod download

RUN go build -ldflags "-s -w" -o /application/build/myc main.go

FROM registry.cn-shanghai.aliyuncs.com/star_base/golang-arm:1.19.1

WORKDIR /target

# 复制编译后的程序
COPY --from=builder /application/build/myc /target/myc
COPY --from=builder /application/resources/ /target/resources
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

EXPOSE 8080
ENTRYPOINT ["/target/myc"]